import 'package:flutter/material.dart';

void main() {
  runApp(const MaterialApp(home: Main()));
}

class Main extends StatefulWidget {
  const Main({super.key});

  @override
  _MainState createState() => _MainState();
}

class _MainState extends State<Main> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(
          'ListView - ,builder用法',
          style: TextStyle(color: Colors.white),
        ),
        backgroundColor: Colors.deepPurpleAccent,
      ),
      body: Container(
        color: Colors.transparent,
        child: ListView.builder(
          itemBuilder: (BuildContext context, int index) {
            return Container(
              height: 50,
              color: index % 2 == 0 ? Colors.amber : Colors.lightGreenAccent,
              child: Text('$index'),
            );
          },
          itemCount: 20,
        ),
      ),
    );
  }
}
